package cn.ipanel.bigdata.boot.source

import java.sql.{ResultSet, ResultSetMetaData}

/**
 * Author: lzz
 * Date: 2021/11/16 16:15
 */
trait LocalExec {

  def _local_get(sql: String): Seq[Map[String, String]]
  def _local_sql(sql: String): Int
  def _to(rs: ResultSet): Seq[Map[String, String]] = {
    val md: ResultSetMetaData = rs.getMetaData
    val count: Int = md.getColumnCount
    var seq: Seq[Map[String, String]] = Seq()
    while (rs.next()) {
      var map: Map[String, String] = Map()
      for (i <- 0 until count) {
        map = map ++ Map(md.getColumnName(i) -> rs.getString(i))
      }
      seq = seq ++ Seq(map)
    }
    seq
  }
}